from object.unit import Factor
import talib


describe_dc = {
    'sma5': "5K移动平均线因子",
    'sma20': "20K移动平均线因子",
    'std5': "5K标准差",
    'std20': "20K标准差",
    'atr5': "5K真实平均波动幅度",
    'atr20': "20K真实平均波动幅度",
    "atr_rate": "平均真实波幅比率因子",
    'adx': "平均方向性指数",
    'plus_di': "正方向指标",
    "minus_di": "负方向指标",
    "mean": "均值",
    "std": "标准差"
}


class FrontFactor(Factor):
    def __init__(self):
        super().__init__()

    def sma5(self):
        # 因子列生成的逻辑
        self.com_data["sma5"] = talib.SMA(self.close, 5)

    def sma20(self):
        self.com_data["sma20"] = talib.SMA(self.close, 20)

    def std5(self):
        # 因子列生成的逻辑
        self.com_data["std5"] = talib.STDDEV(self.close, 5)

    def std20(self):
        self.com_data["std20"] = talib.STDDEV(self.close, 20)

    def atr5(self):
        # 因子列生成的逻辑
        self.com_data["atr5"] = talib.ATR(self.high, self.low, self.close, 5)

    def atr20(self):
        self.com_data["atr20"] = talib.ATR(self.high, self.low, self.close, 20)

    def atr_rate(self):
        self.com_data["atr_rate"] = talib.ATR(self.high, self.low, self.close) / self.close

    def adx(self):
        self.com_data["adx"] = talib.ADX(self.high, self.low, self.close)

    def plus_di(self):
        self.com_data["plus_di"] = talib.PLUS_DI(self.high, self.low, self.close)

    def minus_di(self):
        self.com_data["minus_di"] = talib.MINUS_DI(self.high, self.low, self.close)

    def mean(self):
        self.com_data["mean"] = talib.SMA(self.close, 20)

    def std(self):
        self.com_data["std"] = talib.STDDEV(self.close, 20)





















